<? 
include"../inc/config.inc.php";
if($_POST[MODE]=="ADD")
{
$teach_id=$_POST[teach_id];
$teach_name=$_POST[teach_name];
$teach_surname=$_POST[teach_surname];
$birth_day =$_POST[birth_day];
$teach_address=$_POST[teach_address];
$teach_phone=$_POST[teach_phone];
$teach_email=$_POST[teach_email];
$picname=$_FILES[teach_pic][name];
$tmp=$_FILES[teach_pic][tmp_name];
copy($tmp,"picture/$picname");
$sql="insert into teacher(teach_id,teach_name,teach_surname,teach_address,teach_phone,teach_email,teach_pic,teach_birth) values('$teach_id','$teach_name','$teach_surname','$teach_address','$teach_phone','$teach_email','$picname','$birth_day')";
mysql_query($sql) or die (mysql_error());
echo"<meta http-equiv='refresh' content='0;URL=teach.php'>";
}
if($_GET[MODE]=="DEL")
{
$teach_id=$_GET[teach_id];
$teach_name=$_GET[teach_name];
$teach_surname=$_GET[teach_surname];
$teach_address=$_GET[teach_address];
$teach_phone=$_GET[teach_phone];
$teach_email=$_GET[teach_email];
$teach_pic=$_GET[teach_pic];
$sql="delete from teacher where teach_id='$teach_id'";
mysql_query($sql) or die (mysql_error());
echo"<meta http-equiv='refresh' content='0;URL=teach.php'>";
}
if($_POST[MODE]=="EDIT")
{
$teach_id=$_POST[teach_id];
$teach_name=$_POST[teach_name];
$teach_surname=$_POST[teach_surname];
$birth_day =$_POST[birth_day];
$teach_address=$_POST[teach_address];
$teach_phone=$_POST[teach_phone];
$teach_email=$_POST[teach_email];
$picname=$_FILES[teach_pic][name];
$tmp=$_FILES[teach_pic][tmp_name];
copy($tmp,"picture/$picname");
$sql="UPDATE teacher set teach_id='$teach_id',teach_name='$teach_name',teach_surname='$teach_surname',teach_address='$teach_address',teach_phone='$teach_phone',teach_email='$teach_email',teach_pic='$picname',teach_birth='$birth_day' where teach_id='$teach_id'";
mysql_query($sql) or die(mysql_error());
echo"<meta http-equiv='refresh' content='0;URL=teach.php'>";
}
?>